﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Charting;
using Telerik.Charting.Styles;
using System.Drawing;

namespace BSCMFF.Web.UserControls
{
    public partial class SurveyQuestionChart : System.Web.UI.UserControl
    {
        public string Question { get; set; }
        public Dictionary<string, int> Results { get; set; }



        protected void Page_Load(object sender, EventArgs e)
        {
            //if (Question != "")
            //{
                ChartSeries chs = new ChartSeries();
                chs.Type = ChartSeriesType.Pie;

                //KeyValuePair<string, int> kvp = new KeyValuePair<string, int>();
                //Results = new Dictionary<string, int>();
                //Results.Add("jeden", 1);
                //Results.Add("dva", 2);
                //Results.Add("tri", 3);

                Dictionary<string, int>.Enumerator en = Results.GetEnumerator();

                //do
                //{
                //    string s = en.Current.Key;
                //}
                //while (en.MoveNext());
                //ChartLegend chl = RadChartQuestion.Legend;//new ChartLegend();
            //chl.Items.Add(

            
                while (en.MoveNext())
                {
                    ChartSeriesItem chi = new ChartSeriesItem();
                    chi.Name = en.Current.Key;
                    chi.YValue = en.Current.Value;
                    //chi.l
                    //chs.
                    chi.Label.TextBlock.Text = en.Current.Value.ToString() ;
                    chs.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
                    chs.Items.Add(chi);

                    //LabelItem li = new LabelItem(en.Current.Key);
                    //li.Appearance.FillStyle.FillType = FillType.Solid;
                    //li.Appearance.FillStyle.MainColor = chi.Appearance.FillStyle.MainColor;
                    //chl.Items.Add(li);
                }
                chs.Appearance.FillStyle.MainColor = Color.Transparent;
                chs.Appearance.FillStyle.FillType = FillType.Solid;
            //chs.Appearance.
                RadChartQuestion.Series.Add(chs);
                RadChartQuestion.ChartTitle.TextBlock.Text = Question;// "Ako sa stotoznujete s novou metodikou BSC ? ";
                //RadChartQuestion.Legend.l = chl;

            //}
        }
    }
}